import {observable, action, configure, runInAction} from 'mobx'
import { getArticleList, deleteArticle } from './ArticleServ'
import { message } from 'antd'

configure({
	enforceActions: 'observed'
})

class Article {
	@observable fuhtml = ''

	@observable articleList = []

	@action
	doGetArticleList = () => {
		getArticleList().then((res) => {
			let tempList = []
			res.data.forEach((item) => {
				tempList.push(item)
			})
			runInAction( () => {
				this.articleList.replace(tempList)
			}) 
		})
	}


	@action
	doDeleteArticle = (params) => {
		deleteArticle(params).then((res) => {
			console.log(res)
			message.success('删除成功')
			this.doGetArticleList()
		})
	}
}

export default Article